This lesson is part of the Tags in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off

Description

Learn about User-Defined Types, an easy way to organize Tags in Ignition.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] In this lesson, we'll talk about a special kind of tag data type in Ignition known as the User Defined Type or UDT for short. User Defined Types allow us to take a custom created tag structure and treat it as a complex data type, something that we can associate with any number of actual tags in the tag browser. UDTs can be quite useful when some part of your desired tag structure is inherently repetitive. Maybe you have 10 motors and you need the exact same tags for each, or maybe you have 100 sensors that all have the same data points. When we create UDTs in cases like these, we provide a clean easy way of organizing and maintaining our tag structure. The first thing you do when working with a UDT is declare a UDT definition. A definition is effectively the master copy of the User Defined Type, and it should fully or mostly define how we want our custom structure to look. Once we set up a definition that outlines our structure, we set up any number of instances which inherit the structure of whatever definition they're derived from.

[01:04] So if we have a UDT definition with a specific couple of tags, each UDT instance will have the same couple of tags. So just to reiterate, a definition declares a UDT structure effectively like a design specification, and then an instance is an actual collection of tags following that specification. Now to see UDTs in action, I'm going to find my tag browser here in the designer, on the left-hand side. Across the top of the tag browser there's two tabs, tags and UDT definitions. If I click over to my UDT definitions tab, we can see that a motor definition here. And if I expand it, I have two tags inside Amps and HOA. We call these our UDT member tags, and every instance of this motor UDT will include those two tags. Effectively, this is the structure we'd like to repeat. Now if I swap back over to my tags tab here, we'll see that we have five instances of our motor UDT, motors one through five here. If I click through some of these, we'll see that the structure is the same across different motors like we'd expect, but the actual values on the member tags are different. That's actually because we've set this UDT to include a parameter.

[02:08] So if I expand this parameters field here, we'll see a MotorNum parameter inside. That value is being used in our Amps and HOA tag configurations to point to the correct motor, we'll explore this more in later videos. Now as configured here, our tagged browser is very organized, we have five clear instances containing tags for our five motors. But as we've mentioned, the other real benefit we're getting here is how easily we can maintain and update our UDTs when we need to. Say for example that we wanted to make a configurable setpoint for each motor, maybe as the basis for an alarm. Well, if I weren't using UDTs, I need to add a new tag manually for each of my motors here, but instead what I can do is go back into the UDT definitions tab, double click on my motor definition, and that will bring up the structure for the definition. And on here, all I need to do is click the little tag plus icon here to add a new tag into my structure. And we'll keep things simple and make it a memory tag here.

[03:05] With that tag selected on the left hand side, I can see the properties on the right, so I'll find the name and change it to setpoint. And then I'll set the value on the tag to 20. Any properties I specify in here will be included in our UDT definition, including alarm, security, scripting and history settings. So if I wanted to I could set up alarms on every instances Amps tag or setup tag change grips on every instance is HOA tag, just by configuring it here in this interface. Now that my setpoint tag is set up, I'll click OK at the bottom. And then I'll find my way back into the tags folder and we can see that our setpoint tag has been added to each of our instances. We didn't have to configure the tag separately five times over, just doing it once in the definition is all it takes. We'll be exploring additional UDT features in later videos, but in general UDTs are a great way of keeping an organized and maintainable tag structure when any part of your tag structure is regularly repeated.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.